package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.sczhyt.modules.szhy.entity.MeetingNoticeReceiveEntity;
import cn.sczhyt.modules.szhy.service.MeetingNoticeReceiveService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;



/**
 * 通知接收表
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-04-02 10:15:15
 */
@RestController
@RequestMapping("szhy/meetingnoticereceive")
public class MeetingNoticeReceiveController {
    @Autowired
    private MeetingNoticeReceiveService meetingNoticeReceiveService;

    /**
     * 列表
     */
    @RequestMapping("/list/{noticeId}")
    public R list(@PathVariable String noticeId){

         List<MeetingNoticeReceiveEntity> list = meetingNoticeReceiveService.getByNoticeId(noticeId);


        return R.ok().put("data",list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{noticeReceiveId}")
    public R info(@PathVariable("noticeReceiveId") String noticeReceiveId){

		MeetingNoticeReceiveEntity meetingNoticeReceive = meetingNoticeReceiveService.getById(noticeReceiveId);

        return R.ok().put("meetingNoticeReceive", meetingNoticeReceive);
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MeetingNoticeReceiveEntity meetingNoticeReceive){

		meetingNoticeReceiveService.save(meetingNoticeReceive);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MeetingNoticeReceiveEntity meetingNoticeReceive){
		meetingNoticeReceiveService.updateById(meetingNoticeReceive);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] noticeReceiveIds){
		meetingNoticeReceiveService.removeByIds(Arrays.asList(noticeReceiveIds));

        return R.ok();
    }

    /**
     * 批量添加消息接收人
     */
    @ApiOperation("批量添加消息接收人")
    @PutMapping("/add/{noticeId}")
    public R add(@RequestBody String noticeReceiveIds,@PathVariable("noticeId") String noticeId){



        meetingNoticeReceiveService.addReceiver(noticeReceiveIds,noticeId);

        return R.ok();
    }


}
